package solutions.face.easy;

import solutions.lib.BaseSolution;

/**
 * @author lizhidong
 * <a href="https://leetcode-cn.com/problems/string-to-url-lcci/">面试题 01.03. URL化</a>
 */
public class Solution01_03 extends BaseSolution {

    public String replaceSpaces(String S, int length) {
        StringBuilder rst = new StringBuilder();
        int p = 0;
        while (p < length) {
            char c = S.charAt(p++);
            rst.append(c == ' ' ? "%20" : c);
        }
        return rst.toString();
    }

    public static void main(String[] args) {
        Solution01_03 solution = new Solution01_03();
    }
}